package com.mcc.app.materials.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.materials.domain.SinterMaterials;
import com.mcc.app.materials.service.ISinterMaterialsService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 物料管理
 *
 * @author gxy
 * @date 2025-04-03
 */
@Api(tags = "物料管理")
@RestController
@RequestMapping("/materials/materials")
public class SinterMaterialsController extends BaseController {

    @Autowired
    private ISinterMaterialsService sinterMaterialsService;

    @ApiOperation("查询物料管理列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('materials:materials:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<SinterMaterials>> list(SinterMaterials sinterMaterials) {
        List<SinterMaterials> list = sinterMaterialsService.selectSinterMaterialsList(sinterMaterials);
        return getDataTable(list);
    }

    @ApiOperation("查询物料管理列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('materials:materials:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<SinterMaterials>> page(SinterMaterials sinterMaterials) {
        startPage();
        List<SinterMaterials> list = sinterMaterialsService.selectSinterMaterialsList(sinterMaterials);
        return getDataTable(list);
    }

    @ApiOperation("获取物料管理详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('materials:materials:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<SinterMaterials> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sinterMaterialsService.selectSinterMaterialsById(id));
    }

    @ApiOperation("新增物料管理")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('materials:materials:add')")
    @Log(title = "物料管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SinterMaterials sinterMaterials) {
        return toAjax(sinterMaterialsService.insertSinterMaterials(sinterMaterials));
    }

    @ApiOperation("修改物料管理")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('materials:materials:edit')")
    @Log(title = "物料管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SinterMaterials sinterMaterials) {
        return toAjax(sinterMaterialsService.updateSinterMaterials(sinterMaterials));
    }

    @ApiOperation("删除物料管理")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('materials:materials:remove')")
    @Log(title = "物料管理", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sinterMaterialsService.deleteSinterMaterialsByIds(ids));
    }
}
